using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CodePlex.SpaceBlock;
using CodePlex.Resourceful;
using System.Diagnostics;
using CodePlex.Resourceful.Amazon.S3;

namespace CodePlex.SpaceBlock.UI.Controls.Tools
{
    public partial class S3SettingsControl : BaseControl
    {
      
        public S3SettingsControl()
        {
            InitializeComponent();

            _lookupLink.Text = Properties.Messages.Options_S3_AmazonLookup;
            _createLink.Text = Properties.Messages.Options_S3_AmazonSignup;
            
            _defaultTransferACLBox.DataSource = S3DefaultTransferACL.All;


        }

        public void Initialize(FileSystemInfo info)
        {
            // default service host = s3 host
            if (string.IsNullOrEmpty(info.PublicSettings.GetIfExists(UIConstants.S3Settings.ServiceHost)))
            {
                info.PublicSettings[UIConstants.S3Settings.ServiceHost] = S3Constants.Host;
            }

            UIUtils.Bind(_idBox, info.PublicSettings, UIConstants.S3Settings.AWSAccessKeyID);
            UIUtils.Bind(_secretKeyBox, info.PrivateSettings, UIConstants.S3Settings.AWSSecretAccessKey);
            UIUtils.Bind(_useSSLCheck, info.PublicSettings, UIConstants.S3Settings.UseSSL);
            UIUtils.Bind(_defaultTransferACLBox, info.PublicSettings, UIConstants.S3Settings.DefaultTransferACL);
            UIUtils.Bind(_serviceHostBox, info.PublicSettings, UIConstants.S3Settings.ServiceHost);
        }

        private void _lookupLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(Properties.Messages.Urls_Amazon_Lookup);
        }

        private void _createLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(Properties.Messages.Urls_Amazon_Signup);
        }

       
    }
}

